Skip to content

[ernie-image] use concrete Mistral3Model / Ministral3ForCausalLM types#13687

Open
akshan-main wants to merge 1 commit intohuggingface:mainfrom
akshan-main:ernie-image-concrete-types
Open

[ernie-image] use concrete Mistral3Model / Ministral3ForCausalLM types#13687
akshan-main wants to merge 1 commit intohuggingface:mainfrom
akshan-main:ernie-image-concrete-types

Conversation

@akshan-main
Copy link
Copy Markdown
Contributor

What does this PR do?

Follow-up to #13663 (per @asomoza's review there): replace the AutoModel / AutoModelForCausalLM references for text_encoder and pe with the concrete Mistral3Model / Ministral3ForCausalLM so the loaded checkpoint matches the declared types.

To avoid breaking installs with older transformers (Ministral3ForCausalLM is only in 5.0+, Mistral3Model is in 4.50+):

  • Standard: TYPE_CHECKING + string annotations on __init__ so the imports never run at module load. _get_signature_types uses get_type_hints and falls back gracefully when a name can't be resolved.
  • Modular encoders.py: try/except import that aliases the concrete class when available and falls back to AutoModel / AutoModelForCausalLM otherwise. The ComponentSpec then references the alias.

So users on recent transformers get the silenced warning; users on older transformers keep working as before.

Before submitting

Who can review?

@yiyixuxu @asomoza

@asomoza
Copy link
Copy Markdown
Member

asomoza commented May 7, 2026

thanks @akshan-main for what understand, this is not the best fix, since with the fallback (as it was before) it will still not work because the models are not present in transformers. So probably instead of the fallback we should raise an error but the version depends if they use or not the PE @yiyixuxu WDYT?

@yiyixuxu
Copy link
Copy Markdown
Collaborator

yiyixuxu commented May 7, 2026

ohh I just thought it was an issue with CI on our end, not something you need to fix
can you just keep the change (not the fix), so that we can see if the CI fails here and look into it

@akshan-main akshan-main force-pushed the ernie-image-concrete-types branch from 750ee11 to 51321f1 Compare May 8, 2026 01:25
@akshan-main
Copy link
Copy Markdown
Contributor Author

@yiyixuxu kept just the type change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants